$(function () {
    initPage();
    function initPage() {
        let data = getSearchInfo();
        let Pr_itemInfo = new Promise( (resolve,reject)=>{
            $.ajax({
                url : '/projectDetails/excellent_works_details_productt.do',
                data : data,
                success : function (data) {
                    if( data.status == 0 ){
                        resolve( data );
                    }else if( data.status == 10 ){
                        reject( data );
                    }
                }
            })
        } );
        Pr_itemInfo.then( (data)=>{
            if( data.status == 0 ){
                To_itemInfo( data.data );
            }
        });
    }
    function To_itemInfo( info ) {
        console.log(info);
        $('#item_team').text(info.team);
        $('#item_projectgrade').text(info.projectgrade);
        $('#item_addprojectstuname').text(info.addprojectstuname);
        $('#item_instructor').text(info.instructor);
        $('#item_getprize').text(info.getprize);
        $('#item_projectdetailed').html(info.projectdetailed);
        $('#item_Name').text(info.projectname);
        $('#item_coverurl').attr('src', info.coverurl );
        console.log(info);
        let FilesName = info.evidenceid.split('|');
        let FilesUrl = info.evidenceurl.split('|');
        $('#files-list').html('');
        FilesName.forEach( (item,index)=>{
            if(item !== ''){
                let DOM = $('<span class="text-lowercase">' +
                    '<a href="'+ FilesUrl[index] +'" download="'+ item +'" class="mar-10 mar-l">'+ item +'<i class="glyphicon glyphicon-download-alt"></i></a>' +
                    '' +
                    '</span>');
                DOM.appendTo( $('#files-list') );
            }
        } );
        if( $('#files-list').children().length == 0 ){
            $('#files-list').append($('<span>暂无附件</span>'))
        }
    }
});